﻿/*--------------------------------------------------------------
 * Author : Shine K Velayudhan 
 ---------------------------------------------------------------*/
namespace IQN.Logging
{
    public static class LogConfig
    {
        public static MessageLevel GetThreshold(string loggerName)
        {
            Logger logger = null;
            return (LogManager.TheLoggerTree.TryGetLogger(loggerName, out logger) ? logger.Threshold : LogManager.TheLoggerTree.RootLogger.Threshold);
        }

        public static void ResetThreshold(string loggerName)
        {
            Logger logger = null;
            if (LogManager.TheLoggerTree.TryGetLogger(loggerName, out logger))
            {
                logger.ClearThreshold();
            }
        }

        public static void SetThreshold(string loggerName, MessageLevel threshold)
        {
            LogManager.TheLoggerTree.GetLogger(loggerName).Threshold = threshold;
        }

        public static MessageLevel DefaultThreshold
        {
            get
            {
                return LogManager.TheLoggerTree.RootLogger.Threshold;
            }
            set
            {
                LogManager.TheLoggerTree.RootLogger.Threshold = value;
            }
        }
    }
}
